/**
 * 项目：ystree
 * 模块：树对象 可表示一棵完整的树结构
 * 继承TreeNode
 * 作者：yangjianliang
 * 日期：2007-6-22
 */
package net.ysen.tree.entitybean;

import java.util.ArrayList;
import java.util.List;

public class TreeBean extends TreeNode{

//	private static final Log log = LogFactory.getLog(TreeBean.class);

	public TreeBean(){
	}
	
	public TreeBean(final boolean showCheckBox){
		TreeBean.showCheckBox = showCheckBox;
	}
	
    private static boolean showCheckBox = true;//是否显示checkbox
	private boolean rootNode = false;//是否是树根
	private boolean footNode = false;//是否是同级的最后一个节点
	private boolean endNode = false;//是否是整个树的最后一个节点
	
//    private Set<TreeBean> treeNode = new HashSet<TreeBean>(0);//该节点的子节点集合
    private List<TreeBean> sonNode = null;//该节点的子节点集合（如果没有子节点则为null值）

	public static boolean isShowCheckBox() {
		return showCheckBox;
	}

	public static void setShowCheckBox(boolean showCheckBox) {
		TreeBean.showCheckBox = showCheckBox;
	}

	/**
	 * 为该节点新加一个子节点
	 * @param treeNode
	 */
    public void addSonNode(TreeBean treeNode) {
    	if( this.sonNode == null ) {
    		this.sonNode = new ArrayList<TreeBean>(1);
    	}
    	this.sonNode.add(treeNode);
    }
    
    /**
     * 删除该节点下的某个子节点
     * @param treeNode
     */
    public void removeSonNode(TreeBean treeNode){
    	this.sonNode.remove(treeNode);
    }

	public List<TreeBean> getSonNode() {
		return sonNode;
	}

	public void setSonNode(List<TreeBean> sonNode) {
		this.sonNode = sonNode;
	}

	public boolean isRootNode() {
		return rootNode;
	}

	public void setRootNode(boolean rootNode) {
		this.rootNode = rootNode;
	}

	public boolean hasSonNode() {
		return sonNode!=null && !sonNode.isEmpty();
	}

	public boolean isFootNode() {
		return footNode;
	}

	public void setFootNode(boolean footNode) {
		this.footNode = footNode;
	}

	public boolean isEndNode() {
		return endNode;
	}

	public void setEndNode(boolean endNode) {
		this.endNode = endNode;
	}

}
